package com.example.backupgeo.controller;

import com.example.backupgeo.entity.Teacher;
import com.example.backupgeo.service.TeacherService;
import com.example.backupgeo.util.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacher")
@Api(value = "提供老师的管理接口",tags = "老师管理")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @ApiOperation("查询老师信息列表接口")
    @GetMapping("/list")
    public ResultVO findAll(){
        return teacherService.findAll();
    }

    @ApiOperation("查询老师信息接口")
    @RequestMapping(value = "/id",method = RequestMethod.GET)
    public ResultVO queryUserById(String id){
        return teacherService.queryTeacherInfoById(id);
    }

    @ApiOperation("添加老师接口")
    @RequestMapping(value = "/addTeacher",method = RequestMethod.POST)
    public ResultVO addUser(@RequestBody Teacher teacher){
        return teacherService.addTeacher(teacher);
    }

    @ApiOperation("更新老师信息接口")
    @PutMapping("/update")
    public ResultVO update(@RequestBody Teacher teacher) {
        return teacherService.update(teacher);
    }

    @ApiOperation("注销老师信息接口")
    @DeleteMapping("/delete")
    public ResultVO delete(Integer id) {
        return teacherService.deleteTeacher(id);
    }

}
